package com.library.bean;

import java.util.List;

public class Page<T> {
	
	private List<T> data;// 表示真正的数据
	
	private int pageNum;// 表示当前的页码
	
	private int pageSize;// 一页的大小
	
	private int totalRows; // 总数据的条数
	
	private int totalPageNum;// 总页数
	
	private boolean hasNext;// 是否有下一页
	
	private boolean hasPrev;//是否有 上一页

	public List<T> getData() {
		return data;
	}

	public void setData(List<T> data) {
		this.data = data;
	}

	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getTotalRows() {
		return totalRows;
	}

	public void setTotalRows(int totalRows) {
		this.totalRows = totalRows;
	}

	public int getTotalPageNum() {
		return totalPageNum;
	}

	public void setTotalPageNum(int totalPageNum) {
		this.totalPageNum = totalPageNum;
	}

	public boolean isHasNext() {
		return hasNext;
	}

	public void setHasNext(boolean hasNext) {
		this.hasNext = hasNext;
	}

	public boolean isHasPrev() {
		return hasPrev;
	}

	public void setHasPrev(boolean hasPrev) {
		this.hasPrev = hasPrev;
	}

	public Page() {
		super();
		// TODO Auto-generated constructor stub
	}

	public Page(List<T> data, int pageNum, int pageSize, int totalRows) {
		
		this.data = data;
		this.pageNum = pageNum;
		this.pageSize = pageSize;
		this.totalRows = totalRows;
		
		this.totalPageNum = totalRows % pageSize == 0 ? totalRows / pageSize : (totalRows / pageSize)+1 ;
		this.hasNext = pageNum == totalPageNum ? false:true;
		this.hasPrev = pageNum <= 1 ? false:true;
	}
	
	
	
}
